package com.servlet.dba;

import com.enitiy.Dba;
import com.service.dba.DbaServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 创建作者 ：MySunshine
 * 创建时间 2022/10/26 17:50
 * 项目名称 SHUSHAN
 */
@WebServlet("/DbaUpdate")
public class DbaUpdate extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String num = req.getParameter("num");
        String name = req.getParameter("name");
        String pwd = req.getParameter("pwd");
        String rank = req.getParameter("rank");
        DbaServiceImpl dsi = new DbaServiceImpl();
        boolean b = dsi.DbaUpdateByNum(new Dba(name, pwd, Integer.parseInt(rank), Integer.parseInt(num)));
        if (b){
            System.out.println("修改成功！");
            req.getRequestDispatcher("/page/dba/dbaMain.jsp").forward(req,resp);
        }else {
            System.out.println("修改失败！");
        }
    }
}
